import React, { PureComponent } from 'react';
import {
    Row,
    Col,
    Card,
    Form,
    Button,
    Input,
    DatePicker,
    Table,
    Select,
    Icon,
    Divider,
    Popconfirm,
    Modal,
    message,
    Alert,
    Steps
} from 'antd';
import moment from 'moment';
import { connect } from 'dva';
import router from 'umi/router';
// import Editor from '../Editor'
const FormItem = Form.Item;
const Option = Select.Option;

@Form.create()
@connect(({ assessment }) => ({
    companyList: assessment.companyList
}))
export default class EmergAddPerson extends PureComponent {
    constructor(props) {
        super(props);
        this.state = {
            visible: false,
            editorContent: ''
        };
        this.dispatch = this.props.dispatch;
    }
    submitEditValues = () => {
        this.props.form.validateFields((err, values) => {
            if (!err) {
                const hide = message.loading('正在新增...', 0);
                this.dispatch({
                    type: 'emergency/fetchEmergencyAddEquip',
                    payload: {
                        model: values,
                    },
                    callback: response => {
                        hide();
                        if (response.status) {
                            message.success('新增成功');
                            this.setState({ visible: false });
                            this.props.fetchQueryEquipList();
                        } else {
                            message.error('新增失败');
                            console.log(response.ErrorMessage);
                        }
                    },
                });
            }

        })
    }
    componentDidMount() {
        // debugger
        this.props.OnRef({ ref: this, type: 'AddForm' });
    }
    render() {
        const { getFieldDecorator } = this.props.form;
        const { companyList } = this.props;

        const formItemLayout = {
            labelCol: {
                xs: { span: 24 },
                sm: { span: 12 },
            },
            wrapperCol: {
                xs: { span: 24 },
                sm: { span: 24 },
            },
        };
        const width = '300px';
        return (
            <><Modal
                title="新增"
                width={'80%'}
                style={{ top: 20 }}
                destroyOnClose
                visible={this.state.visible}
                onOk={() => {
                    this.submitEditValues();
                }}
                onCancel={() => {
                    this.setState({ visible: false });
                }}

            >
                <Card style={{ margin: '5px 0' }}>
                    <Form labelAlign="left" layout={'inline'} {...formItemLayout}>
                        <Row>
                            <Col span={8} offset={4}>
                                <FormItem label="装备表名称" >
                                    {getFieldDecorator('zbbmc', {
                                        rules: [{ required: true, message: '请填写人员表名称！' }],
                                        initialValue: null,
                                    })(<Input placeholder="装备表名称" style={{ width: width }} />)}
                                </FormItem>
                            </Col>
                            <Col span={12}>
                                <FormItem label="建设部门" >
                                    {getFieldDecorator('jsbm', { rules: [{ required: true, message: '请选择建设部门！' }], initialValue: null })(
                                        <Select style={{ width: width }}>
                                            {companyList && companyList.map(item =>
                                                <Option key={item.Id} value={item.Id}>
                                                    {item.Name}
                                                </Option>
                                            )}
                                        </Select>
                                    )}
                                </FormItem></Col>
                        </Row>
                        <Row>
                        <Col span={8} offset={4}>
                                <FormItem label="负责人" >
                                    {getFieldDecorator('fzra', {
                                        initialValue: null,
                                    })(<Input placeholder="负责人" style={{ width: width }} />)}
                                </FormItem>
                            </Col>
                            <Col span={12}>
                                <FormItem label="负责人职务" >
                                    {getFieldDecorator('fzrazw', {
                                        initialValue: null,
                                    })(<Input placeholder="负责人职务" style={{ width: width }} />)}
                                </FormItem></Col>
                        </Row>
                        <Row>
                        <Col span={8} offset={4}>
                                <FormItem label="负责人联系方式" >
                                    {getFieldDecorator('fzralxfs', {
                                        initialValue: null,
                                    })(<Input placeholder="负责人联系方式" style={{ width: width }} />)}
                                </FormItem>
                            </Col>
                        </Row>
                        <Row>
                        <Col span={8} offset={4}>
                                <FormItem label="应急联系人" >
                                    {getFieldDecorator('yjlxra', {
                                        initialValue: null,
                                    })(<Input placeholder="应急联系人" style={{ width: width }} />)}
                                </FormItem>
                            </Col>
                            <Col span={12}>
                                <FormItem label="应急联系人职务" >
                                    {getFieldDecorator('yjlxrazw', {
                                        initialValue: null,
                                    })(<Input placeholder="应急联系人职务" style={{ width: width }} />)}
                                </FormItem></Col>
                        </Row>
                        <Row>
                        <Col span={8} offset={4}>
                                <FormItem label="应急联系人联系方式" >
                                    {getFieldDecorator('yjlxralxfs', {
                                        initialValue: null,
                                    })(<Input placeholder="应急联系人联系方式" style={{ width: width }} />)}
                                </FormItem>
                            </Col>
                        </Row>
                        <Row>
                        <Col span={8} offset={4}>
                                <FormItem label="备注" >
                                    {getFieldDecorator('bz', {
                                        initialValue: null,
                                    })(<Input.TextArea placeholder="备注" style={{ width: '400px' }} rows={3} />)}
                                </FormItem>
                            </Col>
                        </Row>
                    </Form>
     
                </Card>
            </Modal></>
        )
    }
}